//Accepted
#include <cstdio>
int n, m, i, j, k, r= 4000000, p[100], a, b, t;
bool adj[100][100];

void read(){
	scanf("%d%d", &n, &m);
	for(i=0;i<n;i++)scanf("%d",&p[i]);
	for(i=0;i<m;i++){
		scanf("%d%d",&a, &b);
		--a;--b;
		adj[a][b]=adj[b][a]=1;
	}
}
int process(){
	for(i=0;i<n;i++)
		for(j=0;j<n;j++){
			if(adj[i][j]){
				for(k=j+1;k<n;k++){
					if(adj[i][k])
					if(adj[j][k]){
						t = p[i]+p[j]+p[k];
						if(t<r)r=t;
					}
				}	
			}
		}
	
	if(r==4000000)printf("-1");
	else printf("%d", r);
}
int main(){
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	read();
	process();
	return 0;
}
